package com.xique.park.controller.auto;

import java.util.Arrays;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xique.common.log.annotation.Log;
import com.xique.common.log.enums.BusinessType;
import com.xique.common.security.annotation.PreAuthorize;
import com.xique.park.bean.domain.ParkChargeRuleComm;
import com.xique.park.service.service.IParkChargeRuleCommService;
import com.xique.common.core.web.controller.BaseController;
import com.xique.common.core.web.domain.AjaxResult;
import com.xique.common.core.utils.poi.ExcelUtil;
import com.xique.common.core.web.page.TableDataInfo;

/**
 * 计费价格-commController
 * 
 * @author xique
 * @date 2021-12-09
 */
@RestController
@RequestMapping("/chargeRuleComm")
public class ParkChargeRuleCommController extends BaseController
{
    @Autowired
    private IParkChargeRuleCommService parkChargeRuleCommService;

    /**
     * 查询计费价格-comm列表
     */
    @PreAuthorize(hasPermi = "park:comm:list")
    @GetMapping("/list")
    public TableDataInfo list(ParkChargeRuleComm parkChargeRuleComm)
    {
        startPage();
        List<ParkChargeRuleComm> list = parkChargeRuleCommService.selectParkChargeRuleCommList(parkChargeRuleComm);
        return getDataTable(list);
    }

    /**
     * 导出计费价格-comm列表
     */
    @PreAuthorize(hasPermi = "park:comm:export")
    @Log(title = "计费价格-comm", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ParkChargeRuleComm parkChargeRuleComm) throws IOException
    {
        List<ParkChargeRuleComm> list = parkChargeRuleCommService.selectParkChargeRuleCommList(parkChargeRuleComm);
        ExcelUtil<ParkChargeRuleComm> util = new ExcelUtil<ParkChargeRuleComm>(ParkChargeRuleComm.class);
        util.exportExcel(response, list, "计费价格-comm数据");
    }

    /**
     * 获取计费价格-comm详细信息
     */
    @PreAuthorize(hasPermi = "park:comm:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(parkChargeRuleCommService.selectParkChargeRuleCommById(id));
    }

    /**
     * 新增计费价格-comm
     */
    @PreAuthorize(hasPermi = "park:comm:add")
    @Log(title = "计费价格-comm", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ParkChargeRuleComm parkChargeRuleComm)
    {
        return toAjax(parkChargeRuleCommService.insertParkChargeRuleComm(parkChargeRuleComm));
    }

    /**
     * 修改计费价格-comm
     */
    @PreAuthorize(hasPermi = "park:comm:edit")
    @Log(title = "计费价格-comm", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ParkChargeRuleComm parkChargeRuleComm)
    {
        return toAjax(parkChargeRuleCommService.updateParkChargeRuleComm(parkChargeRuleComm));
    }

    /**
     * 删除计费价格-comm
     */
    @PreAuthorize(hasPermi = "park:comm:remove")
    @Log(title = "计费价格-comm", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(parkChargeRuleCommService.deleteParkChargeRuleCommByIds(Arrays.asList(ids)));
    }
}
